<html>
<head><meta charset="utf-8"><title>Where is `va_list` defined for FFI? · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Where.20is.20.60va_list.60.20defined.20for.20FFI.3F.html">Where is `va_list` defined for FFI?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="213715864"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Where%20is%20%60va_list%60%20defined%20for%20FFI%3F/near/213715864" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Where.20is.20.60va_list.60.20defined.20for.20FFI.3F.html#213715864">(Oct 18 2020 at 17:15)</a>:</h4>
<p>The aarch64-apple-darwin tests have a failure in <code>src/test/ui/abi/variadic-ffi</code>. Brief searching found <a href="https://developer.apple.com/documentation/xcode/writing_arm64_code_for_apple_platforms">this</a>:</p>
<blockquote>
<p>Because of these changes, the type <code>va_list</code> is an alias for <code>char*</code>, and not for the struct type in the generic procedure call standard.</p>
</blockquote>
<p>I haven't looked yet (popping in and out of computer range today), but figured I'd ask here in case anyone is bored (also because <span class="user-mention" data-user-id="133247">@bjorn3</span> was interested)</p>



<a name="213715920"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Where%20is%20%60va_list%60%20defined%20for%20FFI%3F/near/213715920" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Where.20is.20.60va_list.60.20defined.20for.20FFI.3F.html#213715920">(Oct 18 2020 at 17:16)</a>:</h4>
<p>My guess is either in libc (which probably needs to be updated for this anyway, somehow) or something in the compiler directly, as we have the special handling of <code>...</code></p>



<a name="213716016"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Where%20is%20%60va_list%60%20defined%20for%20FFI%3F/near/213716016" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Where.20is.20.60va_list.60.20defined.20for.20FFI.3F.html#213716016">(Oct 18 2020 at 17:18)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/blob/master/library/core/src/ffi.rs">https://github.com/rust-lang/rust/blob/master/library/core/src/ffi.rs</a><br>
<a href="https://github.com/rust-lang/rust/blob/a78a62fc996ba16f7a111c99520b23f77029f4eb/compiler/rustc_codegen_ssa/src/mir/mod.rs#L391">https://github.com/rust-lang/rust/blob/a78a62fc996ba16f7a111c99520b23f77029f4eb/compiler/rustc_codegen_ssa/src/mir/mod.rs#L391</a><br>
<a href="https://github.com/rust-lang/rust/blob/a78a62fc996ba16f7a111c99520b23f77029f4eb/compiler/rustc_codegen_ssa/src/mir/block.rs#L235">https://github.com/rust-lang/rust/blob/a78a62fc996ba16f7a111c99520b23f77029f4eb/compiler/rustc_codegen_ssa/src/mir/block.rs#L235</a></p>



<a name="213717223"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Where%20is%20%60va_list%60%20defined%20for%20FFI%3F/near/213717223" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Where.20is.20.60va_list.60.20defined.20for.20FFI.3F.html#213717223">(Oct 18 2020 at 17:48)</a>:</h4>
<p>Oh right, people are working on defining variadic functions in Rust as well.</p>



<a name="213717224"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Where%20is%20%60va_list%60%20defined%20for%20FFI%3F/near/213717224" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Where.20is.20.60va_list.60.20defined.20for.20FFI.3F.html#213717224">(Oct 18 2020 at 17:48)</a>:</h4>
<p>Forgot about that.</p>



<a name="213717250"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Where%20is%20%60va_list%60%20defined%20for%20FFI%3F/near/213717250" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Where.20is.20.60va_list.60.20defined.20for.20FFI.3F.html#213717250">(Oct 18 2020 at 17:49)</a>:</h4>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="w">            </span><span class="k">if</span><span class="w"> </span><span class="n">fx</span><span class="p">.</span><span class="n">fn_abi</span><span class="p">.</span><span class="n">c_variadic</span><span class="w"> </span><span class="o">&amp;&amp;</span><span class="w"> </span><span class="n">arg_index</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="n">fx</span><span class="p">.</span><span class="n">fn_abi</span><span class="p">.</span><span class="n">args</span><span class="p">.</span><span class="n">len</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">                </span><span class="kd">let</span><span class="w"> </span><span class="n">arg_ty</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">fx</span><span class="p">.</span><span class="n">monomorphize</span><span class="p">(</span><span class="o">&amp;</span><span class="n">arg_decl</span><span class="p">.</span><span class="n">ty</span><span class="p">);</span><span class="w"></span>

<span class="w">                </span><span class="kd">let</span><span class="w"> </span><span class="n">va_list</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">PlaceRef</span>::<span class="n">alloca</span><span class="p">(</span><span class="n">bx</span><span class="p">,</span><span class="w"> </span><span class="n">bx</span><span class="p">.</span><span class="n">layout_of</span><span class="p">(</span><span class="n">arg_ty</span><span class="p">));</span><span class="w"></span>
<span class="w">                </span><span class="n">bx</span><span class="p">.</span><span class="n">va_start</span><span class="p">(</span><span class="n">va_list</span><span class="p">.</span><span class="n">llval</span><span class="p">);</span><span class="w"></span>

<span class="w">                </span><span class="k">return</span><span class="w"> </span><span class="n">LocalRef</span>::<span class="n">Place</span><span class="p">(</span><span class="n">va_list</span><span class="p">);</span><span class="w"></span>
<span class="w">            </span><span class="p">}</span><span class="w"></span>
</code></pre></div>

<p>I think that I need to dig into <code>let arg_ty = fx.monomorphize(&amp;arg_decl.ty)</code> to figure out what <code>ty</code> is.</p>



<a name="213717629"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Where%20is%20%60va_list%60%20defined%20for%20FFI%3F/near/213717629" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Where.20is.20.60va_list.60.20defined.20for.20FFI.3F.html#213717629">(Oct 18 2020 at 17:59)</a>:</h4>
<p>or just fix the definition of <code>VaListImpl</code>, I suppose.</p>



<a name="213719046"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Where%20is%20%60va_list%60%20defined%20for%20FFI%3F/near/213719046" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Where.20is.20.60va_list.60.20defined.20for.20FFI.3F.html#213719046">(Oct 18 2020 at 18:36)</a>:</h4>
<p>Am I failing at my boolean / demorgan's law?</p>
<div class="codehilite" data-code-language="Diff"><pre><span></span><code> #[cfg(any(
     all(not(target_arch = "aarch64"), not(target_arch = "powerpc"), not(target_arch = "x86_64")),
<span class="gd">-    all(target_arch = "aarch64", target_os = "ios"),</span>
<span class="gi">+    all(target_arch = "aarch64", any(target_os = "darwin", target_os = "ios")),</span>
     target_arch = "wasm32",
     target_arch = "asmjs",
     windows
</code></pre></div>

<div class="codehilite" data-code-language="Diff"><pre><span></span><code>     #[cfg(all(
         any(target_arch = "aarch64", target_arch = "powerpc", target_arch = "x86_64"),
<span class="gd">-        any(not(target_arch = "aarch64"), not(target_os = "ios")),</span>
<span class="gi">+        any(not(target_arch = "aarch64"), not(target_os = "darwin"), not(target_os = "ios")),</span>
         not(target_arch = "wasm32"),
         not(target_arch = "asmjs"),
         not(windows)
</code></pre></div>



<a name="213719078"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Where%20is%20%60va_list%60%20defined%20for%20FFI%3F/near/213719078" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Diggsey <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Where.20is.20.60va_list.60.20defined.20for.20FFI.3F.html#213719078">(Oct 18 2020 at 18:37)</a>:</h4>
<p>are they supposed to be opposite?</p>



<a name="213719125"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Where%20is%20%60va_list%60%20defined%20for%20FFI%3F/near/213719125" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Where.20is.20.60va_list.60.20defined.20for.20FFI.3F.html#213719125">(Oct 18 2020 at 18:38)</a>:</h4>
<p>they aren't opposite</p>



<a name="213719127"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Where%20is%20%60va_list%60%20defined%20for%20FFI%3F/near/213719127" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Where.20is.20.60va_list.60.20defined.20for.20FFI.3F.html#213719127">(Oct 18 2020 at 18:38)</a>:</h4>
<p><span class="user-mention" data-user-id="116155">@Jake Goulding</span> yes - there will never be an OS that's both darwin and IOS</p>



<a name="213719140"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Where%20is%20%60va_list%60%20defined%20for%20FFI%3F/near/213719140" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Where.20is.20.60va_list.60.20defined.20for.20FFI.3F.html#213719140">(Oct 18 2020 at 18:38)</a>:</h4>
<p>I think you want <code>all(not(darwin), not(ios))</code>? Not sure what this is doing though</p>



<a name="213719220"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Where%20is%20%60va_list%60%20defined%20for%20FFI%3F/near/213719220" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Where.20is.20.60va_list.60.20defined.20for.20FFI.3F.html#213719220">(Oct 18 2020 at 18:40)</a>:</h4>
<p>(I've never liked <code>cfg</code> syntax for exactly this reason, it's hard to think about)</p>



<a name="213719226"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Where%20is%20%60va_list%60%20defined%20for%20FFI%3F/near/213719226" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Where.20is.20.60va_list.60.20defined.20for.20FFI.3F.html#213719226">(Oct 18 2020 at 18:40)</a>:</h4>
<p>We need a <code>cfg_if_else</code> for this, or at least a convention to put <code>not</code> on the outside so that people don't have to do demorgan in their heads</p>



<a name="213719237"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Where%20is%20%60va_list%60%20defined%20for%20FFI%3F/near/213719237" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Where.20is.20.60va_list.60.20defined.20for.20FFI.3F.html#213719237">(Oct 18 2020 at 18:40)</a>:</h4>
<p>it reminds me a bit of <code>enable_if_t</code> for doing static if in C++ template metaprogramming</p>



<a name="213719245"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Where%20is%20%60va_list%60%20defined%20for%20FFI%3F/near/213719245" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Diggsey <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Where.20is.20.60va_list.60.20defined.20for.20FFI.3F.html#213719245">(Oct 18 2020 at 18:41)</a>:</h4>
<p>if the second is supposed to be opposite the first and you want to push "not" in, then it should be <code>any(not(target_arch = "aarch64"), all(not(target_os = "darwin"), not(target_os = "ios")))</code></p>



<a name="213719523"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Where%20is%20%60va_list%60%20defined%20for%20FFI%3F/near/213719523" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Where.20is.20.60va_list.60.20defined.20for.20FFI.3F.html#213719523">(Oct 18 2020 at 18:48)</a>:</h4>
<blockquote>
<p>you want to push "not" in</p>
</blockquote>
<p><em>I</em> don't want to, but I'm trying to adhere to the surrounding convention :-)</p>



<a name="213719800"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Where%20is%20%60va_list%60%20defined%20for%20FFI%3F/near/213719800" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Where.20is.20.60va_list.60.20defined.20for.20FFI.3F.html#213719800">(Oct 18 2020 at 18:54)</a>:</h4>
<p><span class="user-mention silent" data-user-id="271719">Mario Carneiro</span> <a href="#narrow/stream/182449-t-compiler.2Fhelp/topic/Where.20is.20.60va_list.60.20defined.20for.20FFI.3F/near/213719226">said</a>:</p>
<blockquote>
<p>We need a [...]</p>
</blockquote>
<p>... way to create local cfg abstractions (or ideally any kind of annotation abstractions) <span aria-label="wink" class="emoji emoji-1f609" role="img" title="wink">:wink:</span></p>



<a name="213719809"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Where%20is%20%60va_list%60%20defined%20for%20FFI%3F/near/213719809" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Where.20is.20.60va_list.60.20defined.20for.20FFI.3F.html#213719809">(Oct 18 2020 at 18:54)</a>:</h4>
<p><code>#[cfg(va_list_is_opaque_pointer)]</code></p>



<a name="213719827"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Where%20is%20%60va_list%60%20defined%20for%20FFI%3F/near/213719827" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Where.20is.20.60va_list.60.20defined.20for.20FFI.3F.html#213719827">(Oct 18 2020 at 18:55)</a>:</h4>
<p><span class="user-mention silent" data-user-id="271719">Mario Carneiro</span> <a href="#narrow/stream/182449-t-compiler.2Fhelp/topic/Where.20is.20.60va_list.60.20defined.20for.20FFI.3F/near/213719226">said</a>:</p>
<blockquote>
<p>We need a <code>cfg_if_else</code></p>
</blockquote>
<p>There is <a href="https://crates.io/crates/cfg-if">https://crates.io/crates/cfg-if</a></p>



<a name="213733536"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Where%20is%20%60va_list%60%20defined%20for%20FFI%3F/near/213733536" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Where.20is.20.60va_list.60.20defined.20for.20FFI.3F.html#213733536">(Oct 19 2020 at 00:29)</a>:</h4>
<p>Sigh. PROTIP: the os is "macos", not "darwin", even though the target is darwin.</p>



<a name="213734495"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Where%20is%20%60va_list%60%20defined%20for%20FFI%3F/near/213734495" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Where.20is.20.60va_list.60.20defined.20for.20FFI.3F.html#213734495">(Oct 19 2020 at 00:57)</a>:</h4>
<p>Oh, now I get a segfault in rustc</p>



<a name="213734714"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Where%20is%20%60va_list%60%20defined%20for%20FFI%3F/near/213734714" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Where.20is.20.60va_list.60.20defined.20for.20FFI.3F.html#213734714">(Oct 19 2020 at 01:02)</a>:</h4>
<div class="codehilite"><pre><span></span><code>* thread #2, name = &#39;rustc&#39;, stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
  * frame #0: 0x0000000101cfb840 librustc_driver-1fe4ad1832b7fa58.dylib`llvm::PointerType::get(llvm::Type*, unsigned int) + 44
    frame #1: 0x00000001006e1c4c librustc_driver-1fe4ad1832b7fa58.dylib`llvm::GetElementPtrInst::getGEPReturnType(llvm::Type*, llvm::Value*, llvm::ArrayRef&lt;llvm::Value*&gt;) + 84
    frame #2: 0x00000001006e1b8c librustc_driver-1fe4ad1832b7fa58.dylib`llvm::GetElementPtrInst::Create(llvm::Type*, llvm::Value*, llvm::ArrayRef&lt;llvm::Value*&gt;, llvm::Twine const&amp;, llvm::Instruction*) + 124
    frame #3: 0x0000000100743960 librustc_driver-1fe4ad1832b7fa58.dylib`llvm::IRBuilderBase::CreateConstInBoundsGEP2_32(llvm::Type*, llvm::Value*, unsigned int, unsigned int, llvm::Twine const&amp;) + 232
    frame #4: 0x0000000101c66b28 librustc_driver-1fe4ad1832b7fa58.dylib`LLVMBuildStructGEP + 100
    frame #5: 0x000000010056fa7c librustc_driver-1fe4ad1832b7fa58.dylib`rustc_codegen_llvm::va_arg::emit_va_arg::hbd12257ead86c097 + 1460
    frame #6: 0x0000000100551380 librustc_driver-1fe4ad1832b7fa58.dylib`rustc_codegen_llvm::intrinsic::_$LT$impl$u20$rustc_codegen_ssa..traits..intrinsic..IntrinsicCallMethods$u20$for$u20$rustc_codegen_llvm..builder..Builder$GT$::codegen_intrinsic_call::h2c93142c8bff4ed8 + 3780
    frame #7: 0x000000010045e1f0 librustc_driver-1fe4ad1832b7fa58.dylib`rustc_codegen_ssa::mir::intrinsic::_$LT$impl$u20$rustc_codegen_ssa..mir..FunctionCx$LT$Bx$GT$$GT$::codegen_intrinsic_call::hf721e1c1185ca1c9 + 8300
    frame #8: 0x0000000100455260 librustc_driver-1fe4ad1832b7fa58.dylib`rustc_codegen_ssa::mir::block::_$LT$impl$u20$rustc_codegen_ssa..mir..FunctionCx$LT$Bx$GT$$GT$::codegen_call_terminator::h64e297c7563c6ca0 + 5556
    frame #9: 0x00000001004513d0 librustc_driver-1fe4ad1832b7fa58.dylib`rustc_codegen_ssa::mir::block::_$LT$impl$u20$rustc_codegen_ssa..mir..FunctionCx$LT$Bx$GT$$GT$::codegen_block::h15827faf80ad9e38 + 3496
    frame #10: 0x000000010044f914 librustc_driver-1fe4ad1832b7fa58.dylib`rustc_codegen_ssa::mir::codegen_mir::h5646b40052194582 + 2880
    frame #11: 0x000000010050c364 librustc_driver-1fe4ad1832b7fa58.dylib`rustc_codegen_ssa::base::codegen_instance::h073fedb73c021f27 + 356
    frame #12: 0x000000010056de78 librustc_driver-1fe4ad1832b7fa58.dylib`_$LT$rustc_middle..mir..mono..MonoItem$u20$as$u20$rustc_codegen_ssa..mono_item..MonoItemExt$GT$::define::ha14ac71902a89ca8 + 64
    frame #13: 0x000000010041d2dc librustc_driver-1fe4ad1832b7fa58.dylib`rustc_codegen_llvm::base::compile_codegen_unit::module_codegen::h6a768c7237e0c183 + 424
    frame #14: 0x000000010049383c librustc_driver-1fe4ad1832b7fa58.dylib`rustc_query_system::dep_graph::graph::DepGraph$LT$K$GT$::with_task::h117a820fa292fd67 + 384
    frame #15: 0x000000010041cf34 librustc_driver-1fe4ad1832b7fa58.dylib`rustc_codegen_llvm::base::compile_codegen_unit::h70551f046a3de22d + 404
    frame #16: 0x000000010050ab80 librustc_driver-1fe4ad1832b7fa58.dylib`rustc_codegen_ssa::base::codegen_crate::h2a4ba4a5983f2453 + 3452
    frame #17: 0x0000000100541eb4 librustc_driver-1fe4ad1832b7fa58.dylib`_$LT$rustc_codegen_llvm..LlvmCodegenBackend$u20$as$u20$rustc_codegen_ssa..traits..backend..CodegenBackend$GT$::codegen_crate::h8e575abce6547418 + 48
    frame #18: 0x0000000100395614 librustc_driver-1fe4ad1832b7fa58.dylib`rustc_session::utils::_$LT$impl$u20$rustc_session..session..Session$GT$::time::hc81f120b16dab4d2 + 100
    frame #19: 0x00000001003d0688 librustc_driver-1fe4ad1832b7fa58.dylib`rustc_interface::queries::Queries::ongoing_codegen::ha0f4d22fc34eab33 + 2020
    frame #20: 0x000000010023cc54 librustc_driver-1fe4ad1832b7fa58.dylib`rustc_interface::queries::_$LT$impl$u20$rustc_interface..interface..Compiler$GT$::enter::h40337dd059b7203c + 1912
    frame #21: 0x0000000100228000 librustc_driver-1fe4ad1832b7fa58.dylib`rustc_span::with_source_map::h2d1b097bb6a55888 + 316
    frame #22: 0x0000000100239078 librustc_driver-1fe4ad1832b7fa58.dylib`scoped_tls::ScopedKey$LT$T$GT$::set::h64663797e93bc5ca + 1248
    frame #23: 0x000000010023f990 librustc_driver-1fe4ad1832b7fa58.dylib`std::sys_common::backtrace::__rust_begin_short_backtrace::h4a633d3102afe952 + 536
    frame #24: 0x00000001001eb0f0 librustc_driver-1fe4ad1832b7fa58.dylib`core::ops::function::FnOnce::call_once$u7b$$u7b$vtable.shim$u7d$$u7d$::h7ef58e07b333acf7 + 64
    frame #25: 0x0000000106c59354 libstd-33ceb3979528e430.dylib`std::sys::unix::thread::Thread::new::thread_start::h53fe16d285797710 + 48
</code></pre></div>



<a name="213734811"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Where%20is%20%60va_list%60%20defined%20for%20FFI%3F/near/213734811" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Where.20is.20.60va_list.60.20defined.20for.20FFI.3F.html#213734811">(Oct 19 2020 at 01:05)</a>:</h4>
<p>Of course there's no debug info. Why would there be.</p>



<a name="213734854"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Where%20is%20%60va_list%60%20defined%20for%20FFI%3F/near/213734854" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Where.20is.20.60va_list.60.20defined.20for.20FFI.3F.html#213734854">(Oct 19 2020 at 01:06)</a>:</h4>
<blockquote>
<div class="codehilite"><pre><span></span><code>frame #5: 0x000000010056fa7c librustc_driver-1fe4ad1832b7fa58.dylib`rustc_codegen_llvm::va_arg::emit_va_arg::hbd12257ead86c097 + 1460
</code></pre></div>


</blockquote>
<p>this seems vaguely relevant</p>



<a name="213734940"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Where%20is%20%60va_list%60%20defined%20for%20FFI%3F/near/213734940" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Where.20is.20.60va_list.60.20defined.20for.20FFI.3F.html#213734940">(Oct 19 2020 at 01:09)</a>:</h4>
<p>Absolutely.</p>



<a name="213734960"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Where%20is%20%60va_list%60%20defined%20for%20FFI%3F/near/213734960" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Where.20is.20.60va_list.60.20defined.20for.20FFI.3F.html#213734960">(Oct 19 2020 at 01:09)</a>:</h4>
<p>And it's interesting that it's for an argument.</p>



<a name="213735011"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Where%20is%20%60va_list%60%20defined%20for%20FFI%3F/near/213735011" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Where.20is.20.60va_list.60.20defined.20for.20FFI.3F.html#213735011">(Oct 19 2020 at 01:10)</a>:</h4>
<blockquote>
<p>We currently expose the va_arg intrinsic which should emit the correct LLVM for va_arg for the given architecture and OS. We currently use the LLVM va_arg instruction, but it doesn't emit the correct code for some common OSes and architectures causing us to implement the instruction manually (See [src/librustc_codegen_llvm/va_arg.rs] for details). Since we do not</p>
</blockquote>



<a name="213735012"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Where%20is%20%60va_list%60%20defined%20for%20FFI%3F/near/213735012" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Where.20is.20.60va_list.60.20defined.20for.20FFI.3F.html#213735012">(Oct 19 2020 at 01:10)</a>:</h4>
<p>wild.</p>



<a name="213735020"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Where%20is%20%60va_list%60%20defined%20for%20FFI%3F/near/213735020" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Where.20is.20.60va_list.60.20defined.20for.20FFI.3F.html#213735020">(Oct 19 2020 at 01:11)</a>:</h4>
<p><span class="user-mention" data-user-id="143663">@dlrobertson</span> maybe you might have some context (or additional troubleshooting guidance)</p>



<a name="213735387"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Where%20is%20%60va_list%60%20defined%20for%20FFI%3F/near/213735387" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Where.20is.20.60va_list.60.20defined.20for.20FFI.3F.html#213735387">(Oct 19 2020 at 01:22)</a>:</h4>
<p>build llvm with assertions enabled</p>



<a name="213735396"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Where%20is%20%60va_list%60%20defined%20for%20FFI%3F/near/213735396" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Where.20is.20.60va_list.60.20defined.20for.20FFI.3F.html#213735396">(Oct 19 2020 at 01:22)</a>:</h4>
<p>you'll get a sensible error message that you'll be able to search for.</p>



<a name="213735926"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Where%20is%20%60va_list%60%20defined%20for%20FFI%3F/near/213735926" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Where.20is.20.60va_list.60.20defined.20for.20FFI.3F.html#213735926">(Oct 19 2020 at 01:37)</a>:</h4>
<p>Of course I forgot that when rebuilding with debug info. Thank you. (got to 88% of LLVM too)</p>



<a name="213736470"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Where%20is%20%60va_list%60%20defined%20for%20FFI%3F/near/213736470" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> dlrobertson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Where.20is.20.60va_list.60.20defined.20for.20FFI.3F.html#213736470">(Oct 19 2020 at 01:50)</a>:</h4>
<p>Yeah, the <code>va_arg</code> LLVM intrinsic will not emit the right code in some situations, so we have custom implementations for <code>i686</code> and Aarch64 I believe</p>



<a name="213736486"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Where%20is%20%60va_list%60%20defined%20for%20FFI%3F/near/213736486" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> dlrobertson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Where.20is.20.60va_list.60.20defined.20for.20FFI.3F.html#213736486">(Oct 19 2020 at 01:50)</a>:</h4>
<p>I'm away from a computer right now, so I won't be much help, but I can follow up tomorrow</p>



<a name="213736524"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Where%20is%20%60va_list%60%20defined%20for%20FFI%3F/near/213736524" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> dlrobertson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Where.20is.20.60va_list.60.20defined.20for.20FFI.3F.html#213736524">(Oct 19 2020 at 01:51)</a>:</h4>
<p>And I agree that the <code>cfg</code>s in the <code>VaList</code> implementation are brutal... I would love it if we could find a way to use something like <code>cfg_if</code></p>



<a name="213737838"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Where%20is%20%60va_list%60%20defined%20for%20FFI%3F/near/213737838" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Where.20is.20.60va_list.60.20defined.20for.20FFI.3F.html#213737838">(Oct 19 2020 at 02:26)</a>:</h4>
<p>There is zero rush on any of this. I might poke at it for 15 minutes at a time every few days <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span></p>



<a name="213737868"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Where%20is%20%60va_list%60%20defined%20for%20FFI%3F/near/213737868" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Where.20is.20.60va_list.60.20defined.20for.20FFI.3F.html#213737868">(Oct 19 2020 at 02:27)</a>:</h4>
<blockquote>
<p>we have custom implementations for <code>i686</code> and Aarch64 I believe</p>
</blockquote>
<p>Any pointers to where that code is? (I haven’t looked at all)</p>



<a name="213780995"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Where%20is%20%60va_list%60%20defined%20for%20FFI%3F/near/213780995" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Where.20is.20.60va_list.60.20defined.20for.20FFI.3F.html#213780995">(Oct 19 2020 at 13:01)</a>:</h4>
<div class="codehilite"><pre><span></span><code>------------------------------------------
stderr:
------------------------------------------
Assertion failed: (Ty &amp;&amp; &quot;Invalid GetElementPtrInst indices for type!&quot;), function checkGEPType, file /Users/shepmaster/Projects/rust/src/llvm-project/llvm/include/llvm/IR/Instructions.h, line 897.
</code></pre></div>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>